package com.gxc.controller;

import com.gxc.annotation.MyAnnotation;
import com.gxc.entity.User;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试初始化web-mvc.
 *
 * @author 宫新程
 * @since 2018/12/18 9:38 AM
 */
@RestController
@MyAnnotation("My _ TestController")
public class TestController {

  /** 测试. */
  @RequestMapping("/test/hello")
  public List<User> hello(HttpServletRequest request) throws InterruptedException {

    String contextPath = request.getServletContext().getContextPath();
    System.out.println("contextPath：" + request.getContextPath());

    List<User> userList = new LinkedList<>();
    for (int i = 0; i < 10; i++) {
      User user = new User();
      user.setId(i);
      user.setPassword("pwd_" + i);
      user.setUsername("admin_" + i);
      user.setAge((int) (Math.random() * 100));
      userList.add(user);
    }
    int i = 1 / 0;
    Thread.sleep(10);
    return userList;
  }
}
